/**
This file is part of dbdjasperreport.

Copyright (C) 2008 Kue Vang aka Kou
Licensed under the Eclipse Public License, Version 1.0; 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at http://www.eclipse.org/legal/epl-v10.html 
Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and limitations 
under the License.
**/

import java.math.BigDecimal

class ReportParameter implements Comparable {
    static transients = ["dateBetween1", "dateBetween2","dateGreaterEqual","dateLessEqual",
						"dateEqual","datePastDay","datePastMonth","dateRadioOption","idOperatorSelected",
						"numEqual","numGreaterEqual","numLessEqual","numBetween1","numBetween2","numNotEqual",
						"strInput",	"codeSourceList", "codeSelectedList","idOperatorSelected2"]
	static constraints = {
		id()
		report()
		dataType(blank:false,nullable:false)
		defaultOperator(blank:false,nullable:false)
		parameterDisplayName(blank:false,nullable:false,maxSize:45)
		parameterName(blank:false,nullable:false)
		parameterValue(blank:true,nullable:true)
		parameterValue2(blank:true,nullable:true)
		parameterFilterable(maxSize:1,inList:["Y","N"])
		comments(blank:true,nullable:true,maxSize:400)
		parameterEnded(maxSize:1,inList:["N","Y"])
		dateCreated()
	}
	
	static belongsTo = [report:Report]
	
	Integer id
	Integer	dataType
	Integer	defaultOperator
	String	parameterDisplayName//Name that appears on the Parameters list 
	String	parameterName//Field Name from jasper report. Note: 
	/*parameterValue: use by code, entity, image, or rtf data type. If it's code or entity. You should give a SQL select statment.  
	   Otherwise, it'll be a directory path to the imoge or rtf file.
	*/
	String	parameterValue
	//parameterValue2: use by entity data type. You specify which field from the SQL in parameterValue to be use in the WHERE clause.	
	String  parameterValue2
	String	parameterFilterable//Y=parameter will show in the Parameters list.
	String	comments
	String	parameterEnded//flag that determine if this parameter is still use or not
	Date	dateCreated
	
	//non-database fields	
	Integer	datePastDay
	Integer datePastMonth	
	Date 	dateBetween1
	Date	dateBetween2
	Date	dateGreaterEqual
	Date	dateLessEqual
	Date	dateEqual
	Integer idOperatorSelected
	Integer idOperatorSelected2
	BigDecimal numEqual
	BigDecimal numGreaterEqual
	BigDecimal numLessEqual
	BigDecimal numBetween1
	BigDecimal numBetween2
	BigDecimal numNotEqual
	String	strInput
	List	codeSourceList
	List	codeSelectedList
	
	String toString(){
		parameterDisplayName
	}
		
	int compareTo(obj){
		parameterDisplayName.compareTo(obj.parameterDisplayName)
	}

}
